package cn.sxt.service.impl;

import cn.xbtop.domain.UserAddress;
import cn.xbtop.service.OrderService;
import cn.xbtop.service.UserService;
import com.alibaba.dubbo.config.annotation.Reference;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.List;

/**
 * @author Mxb
 * @version 1.0
 * @date 2020/5/7 21:04
 */
@Service
public class OrderServiceImpl implements OrderService {
    @Reference
    private UserService userService;

    //提供set方法
    //public void setUserService(UserService userService){
    //    this.userService = userService;
    //}
    @HystrixCommand(fallbackMethod = "hello")
    @Override
    public List<UserAddress> initOrder(String userid) {
        return userService.queryAllAddress(userid);
    }

    public List<UserAddress> hello(String userid) {
        UserAddress userAddress = new UserAddress(1,
                "系统出错了，自动执行降级方法", userid);
        return Arrays.asList(userAddress);
    }
}
